package com.atguigu.gulimall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gulimall.product.entity.BaseCategory1;
import com.atguigu.gulimall.product.entity.BaseCategory2;
import com.atguigu.gulimall.product.entity.BaseCategory3;
import com.atguigu.gulimall.product.service.BaseCategory1Service;
import com.atguigu.gulimall.product.service.BaseCategory2Service;
import com.atguigu.gulimall.product.service.BaseCategory3Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author nicc
 * @version 1.0
 * @className CategoryController
 * @description TODO
 * @date 2022-09-26 19:15
 */
@RestController
public class CategoryController {

    @Autowired
    private BaseCategory1Service baseCategory1Service;

    @Autowired
    private BaseCategory2Service baseCategory2Service;

    @Autowired
    private BaseCategory3Service baseCategory3Service;

    @GetMapping("/admin/product/getCategory1")
    public Result getCategory1(){

        List<BaseCategory1> list = baseCategory1Service.list();
        return Result.ok(list);
    }

    @GetMapping("/admin/product/getCategory2/{c1Id}")
    public Result getCategory2(@PathVariable("c1Id")Long c1Id){

        List<BaseCategory2> list = baseCategory2Service.getBaseCategory2List(c1Id);
        return Result.ok(list);
    }

    @GetMapping("/admin/product/getCategory3/{c2Id}")
    public Result getCategory3(@PathVariable("c2Id")Long c2Id){

        List<BaseCategory3> list = baseCategory3Service.getBaseCategory2List(c2Id);
        return Result.ok(list);
    }
}